<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>倒正金字塔</title>
		
	</head>
	<body>
		<input name="aa" type="button" value="打印" onclick="dayin(prompt('请输入行高',' '))"  />
		<script type="text/javascript">
			function dayin(count){
				document.write("打印倒正金字塔直线");
				document.write("<br />");
				if(count%2==1){
					//先打印上半部分
					//外循环控制行高
					var hang = parseInt(count/2+1);
				for (var i = hang;i>0;i--) {
					//内循环控制长度
					var chang = i*2-1;
					document.write("<hr width="+chang*40+"px; color='#000000'  />")
					document.write("<br />");
				}
				//打印下半部分
				for (var k =1 ;k<=hang-1;k++) {
					var chang1 = k*2+1;
					document.write("<hr width="+chang1*40+"px; color='#000000'  />")
					
					document.write("<br />");
				}
			}
				else{
					alert("输入的行高不是奇数！")
				}
			}
		</script>
	</body>
</html>
